package com.ricky.onlineShop.serviceBus.trading;

import com.ricky.common.utils.DateUtils;
import com.ricky.onlineShop.read.trading.service.TradingOrderReadService;
import com.ricky.onlineShop.shop.trading.pojo.TradingOrder;
import com.ricky.onlineShop.shop.trading.service.ITradingOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author staticlan
 * @Date 2024/7/8 15:38
 * @Description:
 */
@Service
@Transactional
public class TradingOrderServiceBus {
    @Autowired
    private TradingOrderReadService tradingOrderReadService;

    @Autowired
    private ITradingOrderService tradingOrderService;
    /**
     * 查询网店订单
     *
     * @param id 网店订单主键
     * @return 网店订单
     */
    public TradingOrder selectTradingOrderById(String id) {
        return tradingOrderReadService.selectTradingOrderById(id);
    }

    /**
     * 查询网店订单列表
     *
     * @param tradingOrder 网店订单
     * @return 网店订单
     */
    public List<TradingOrder> selectTradingOrderList(TradingOrder tradingOrder) {
        return tradingOrderReadService.selectTradingOrderList(tradingOrder);
    }

    /**
     * 查询个人网店订单列表
     *
     * @param tradingOrder 网店订单
     * @return 网店订单
     */
    public List<TradingOrder> selectMyTradingOrderList(TradingOrder tradingOrder) {
        return tradingOrderReadService.selectMyTradingOrderList(tradingOrder);
    }

    /**
     * 新增网店订单
     *
     * @param tradingOrder 网店订单
     * @return 结果
     */
    public int insertTradingOrder(TradingOrder tradingOrder) {
        tradingOrder.setCreateTime(DateUtils.getNowDate());
        return tradingOrderReadService.insertTradingOrder(tradingOrder);
    }

    /**
     * 修改网店订单
     *
     * @param tradingOrder 网店订单
     * @return 结果
     */
    public int updateTradingOrder(TradingOrder tradingOrder) {
        tradingOrder.setUpdateTime(DateUtils.getNowDate());
        return tradingOrderReadService.updateTradingOrder(tradingOrder);
    }

    /**
     * 批量删除网店订单
     *
     * @param ids 需要删除的网店订单主键
     * @return 结果
     */
    public int deleteTradingOrderByIds(String[] ids) {
        return tradingOrderReadService.deleteTradingOrderByIds(ids);
    }

    /**
     * 删除网店订单信息
     *
     * @param id 网店订单主键
     * @return 结果
     */
    public int deleteTradingOrderById(String id) {
        return tradingOrderService.deleteTradingOrderById(id);
    }
}
